#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <DS1307new.h>

/*************************************************** 
 * This is an example for the BMP085 Barometric Pressure & Temp Sensor
 * 
 * Designed specifically to work with the Adafruit BMP085 Breakout 
 * ----> https://www.adafruit.com/products/391
 * 
 * These displays use I2C to communicate, 2 pins are required to  
 * interface
 * Adafruit invests time and resources providing this open source code, 
 * please support Adafruit and open-source hardware by purchasing 
 * products from Adafruit!
 * 
 * Written by Limor Fried/Ladyada for Adafruit Industries.  
 * BSD license, all text above must be included in any redistribution
 ****************************************************/

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;

String czas_string="0-0-0 0:0:0";

void setClock(){
  RTC.stopClock();
  RTC.fillByYMD(2013,1,29);
  RTC.fillByHMS(12,26,0);
  RTC.setTime();
  RTC.startClock();
}


String czas(){
  RTC.getTime(); 
  czas_string = String(RTC.year,DEC)+"-"+String(RTC.month,DEC)+"-"+String(RTC.day,DEC)+" "+String(RTC.hour,DEC)+":"+String(RTC.minute,DEC)+":"+String(RTC.second,DEC);
  return czas_string;
  //Serial.println(czas_string);

  //     Serial.print(RTC.year, DEC);
  //          Serial.print("-");
  //     Serial.print(RTC.month, DEC);
  //          Serial.print("-");
  //     Serial.print(RTC.day, DEC);
  //     
  //     Serial.print(" ");
  //     Serial.print(RTC.hour, DEC);
  //     Serial.print(":");
  //     Serial.print(RTC.minute, DEC);
  //     Serial.print(":");
  //     Serial.println(RTC.second,DEC);
}

void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    while (1) {
    }
  }
  //setClock();
}


void loop() {
  Serial.println(czas());


  Serial.print("Temperature = ");
  Serial.print(bmp.readTemperature());
  Serial.println(" *C");

  Serial.print("Pressure = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pa");

  // Calculate altitude assuming 'standard' barometric
  // pressure of 1013.25 millibar = 101325 Pascal
  Serial.print("Altitude = ");
  Serial.print(bmp.readAltitude());
  Serial.println(" meters");

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
  Serial.print("Real altitude = ");
  Serial.print(bmp.readAltitude(101500));
  Serial.println(" meters");

  Serial.println();
  delay(500);
}


